package com.czk.model.factory.simplefactory.pizzastore.absfactory;

import com.czk.model.factory.simplefactory.pizzastore.pizza.Pizza;

import java.util.Scanner;

public class OrderPizza {
    private AbsFactory absFactory;
    public OrderPizza(AbsFactory absFactory){
        setAbsFactory(absFactory);
    }
    public void setAbsFactory(AbsFactory absFactory) {
        Pizza pizza=null;
        this.absFactory = absFactory;
        String orderType="";
        do {
            orderType=getOrderType();
            pizza=absFactory.createPizza(orderType);
            if (pizza!=null){
                pizza.prepare();
                pizza.bake();
                pizza.cut();
                pizza.box();
            }else {
                System.out.println("订购失败");
                break;
            }
        }while (true);
    }
    private String getOrderType(){
        Scanner scanner=new Scanner(System.in);
        String s=scanner.next();
        return s;
    }

    public static void main(String[] args) {
        new OrderPizza(new BjFactory());
    }
}
